package api

import (
	"app/serializer"
	"app/service"
	"net/http"

	"github.com/gin-gonic/gin"
)

// UserRegister @Tags USER
// @Summary 用户注册
// @Produce json
// @Accept json
// @Router /user/register [post]
func UserRegister(c *gin.Context) {
	var userRegisterService service.UserService
	if err := c.ShouldBind(&userRegisterService); err == nil {
		res := userRegisterService.Register()
		c.JSON(http.StatusOK, res)
	} else {
		c.JSON(http.StatusBadRequest, serializer.ErrorResponse(err))
	}
}

// UserLogin @Tags USER
// @Summary 用户登录
// @Produce json
// @Accept json
// @Router /user/login [post]
func UserLogin(c *gin.Context) {
	var userLoginService service.UserService
	if err := c.ShouldBind(&userLoginService); err == nil {
		res := userLoginService.Login()
		c.JSON(http.StatusOK, res)
	} else {
		c.JSON(http.StatusBadRequest, serializer.ErrorResponse(err))
	}
}
